function affixChange() {
	var str = "";
	if($(".uoloadedFile[isDel='n']").length>=5){
		alert("最多只能上传5个附件");
		return false;
	}
	
    //显示正在上传
    $("#addFileLoading").show();
    $("#addFile").hide(); 
    

    //ajax上传
    $("#uploadForm").ajaxSubmit(function(result) {   
        result = $("<span>" + result + "</span>").text(); 
        
        var obj = eval('(' + result + ')'); 
        if (obj.result) { 
        
        	var div =$("<div class=\"uoloadedFile\" isDel=\"n\"></div>"); 
			div.append($("<span></span>").html(decodeURI(obj.message,"utf-8"))); 
			div.append($("<a href=\"javascript:void(0)\" onclick=\"delUpload(this,'"+obj.saleaffixitemid+"')\">&nbsp;x</a>"));					
		 	div.attr("SALEAFFIXITEMID",obj.saleaffixitemid);
			$("#fileList").append(div);
			
			
	
		 	  
        } else {
            art.dialog({
                icon: 'error',
                lock: true,
                resize: false,
                title: "上传失败",
                content:"上传失败<br />错误消息:"+obj.message
            }); 
        } 
        	
            $("#addFileLoading").hide();
            $("#addFileSpan").html("<input type=\"file\" class=\"uploadFileInput\" id=\"AFFIX\" name=\"AFFIX\" onchange=\"affixChange()\" />"); 
    		$("#addFile").show(); 
    });
} 
function delUpload(obj,id){
	$(obj).parent().attr("isDel","y");
	$(obj).parent().css("display","none");
}

function upload(actionUrl,affixmainid,msg){
		var affixStr="";
		$(".uoloadedFile").each(function(i,o){
			var obj=$(o);
			affixStr += obj.attr("SALEAFFIXITEMID")+";"+obj.attr("isDel")+";;";
		});  
		 
		
		art.dialog( {
			lock : true,
			content : '确定'+msg+'吗?',
			ok : function() {
				art.dialog( {
					id : "loading",
					lock : true,
					drag : false,
					resize : false,
					title : "正在提交..."
				}); 
				
				$.post(actionUrl, {
					affixmainid : affixmainid,
					affixStr : affixStr
				}, function(result) {
					art.dialog( {
						id : 'loading'
					}).close();//关闭等待框 

					result = $("<span>" + result + "</span>").text(); 
        			var obj = eval('(' + result + ')');  
					if (obj.result) {
							art.dialog( {
								icon : "succeed",
								content : msg+"成功!",
								lock : true,
								ok : function() {
									history.go(-1);
								}
							});
						} else {
							art.dialog( {
								icon : "error",
								content : msg+"失败!错误消息:"+obj.message,
								lock : true,
								ok : true
							});
						}
						 
				})
				return true;
			},
			cancelVal : '关闭',
			cancel : true
		});
}